package Day06;

import java.util.Arrays;
import java.util.Random;

public class MethDemo {
    public static void main(String[] args) {
        say();
        say("张三");
        say("张三",25);
        sayHi("张三",34);
        int a=sum(2,3);//sum(2,3)的值就是return返回的变量的值
        System.out.println(a);
        System.out.println(sum(5,6));

        int[] a1=generateArray(5,1000);
        int[] a2=generateArray(10,100);
        System.out.println("a1数组第一个数字是"+a1[0]);
        for (int i=0;i<a1.length;i++){
            System.out.println(a1[i]);
        }
        System.out.println("进行排序");
        Arrays.sort(a1);
        System.out.println("排序后a1数组第一个数字是"+a1[0]);
        for (int i=0;i<a1.length;i++){
            System.out.println(a1[i]);
        }
        sayHello("张三",25);
        sayHello("李四",65);
    }
    public static void say(){ System.out.println("大家好"); }
    public static void say(String name){
        System.out.println("大家好，我叫"+name);
    }
    public static void say(String name,int age){
        System.out.println("大家好，我叫"+name+"，今年"+age+"岁了");
    }

    public static void sayHi(String name,int age){
        System.out.println("大家好，我叫"+name+"，今年"+age+"岁了");//有参无返回值
    }
    public static int sum(int num1,int num2){
        int num=num1+num2;
        return num;//返回num里面的值
        //return num1+num2;//返回num1+num2的值
    }
    public static int[] generateArray(int len,int max){
        Random rand=new Random();
        int[] arr =new int[len];
        for (int i=0;i<arr.length;i++){
            arr[i]=rand.nextInt(max);
        }
        return arr;
    }
    public static void sayHello(String name,int age){
        if (age>=60){
            return;
        }
        System.out.println("大家好，我叫"+name+"，今年"+age+"岁了");
    }
}
